#!/usr/bin/env python3
with open("/dev/shm/read_result", "rb") as f:
    last_num = -1
    while True:
        chunk = f.read(4)
        if not chunk:
            break
        chunk2 = f.read(4)
        num = int.from_bytes(chunk, "little")
        if num != last_num + 1:
            print(num)
        last_num = num
with open("/dev/shm/queue_dump", "rb") as f1, open("/dev/shm/read_result", "rb") as f2:
    count = 0
    while True:
        chunk1 = f1.read(4)
        chunk2 = f2.read(4)
        count += 1
        num1 = int.from_bytes(chunk1, "little")
        num2 = int.from_bytes(chunk2, "little")
        if num1 != num2:
            print(f"{num1} != {num2} at {count}")
            break
        chunk3 = f1.read(4)
        chunk4 = f2.read(4)
        num3 = int.from_bytes(chunk3, "little")
        num4 = int.from_bytes(chunk4, "little")
        if num3 != num4:
            print(f"{num3} != {num4} at {count}")
            break
        if not chunk1:
            break
        if not chunk2:
            break
        if not chunk3:
            break
        if not chunk4:
            break
print("EOF")
